package com.xie.test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.*;

/**
 * @author xiezhendong
 * @date 2021/11/2
 */
public class test1 {

    public static void main(String[] args) {

        JSONArray array = JSON.parseArray(text);
        Map<String, JSONObject> vendorCombineDatumMap = new HashMap<>();
        List<JSONObject> vendorCombineDatumList = new ArrayList<>();

        for (int i = 0; i < array.size(); i++) {
            JSONObject object = array.getJSONObject(i);
            if (VALUE_LIST_DEFAULT_LIST.contains(object.getString("dataKey"))) {
                vendorCombineDatumMap.put(object.getString("dataKey"), object);
            } else {
                vendorCombineDatumMap.put(object.getString("dataKey"), object);
                vendorCombineDatumList.add(object);
            }
        }
        for (String dataKey : VALUE_LIST_DEFAULT_LIST) {
            JSONObject object = vendorCombineDatumMap.get(dataKey);
            if (Objects.nonNull(object)) {
                vendorCombineDatumMap.remove(dataKey);
            }
        }

        if (vendorCombineDatumList.size() > 0) {
            for (JSONObject vendorCombineDatum : vendorCombineDatumList) {
                System.out.println(vendorCombineDatum.getString("dataKey"));
            }
        }

        System.out.println("--------------------------------------");

        if (!vendorCombineDatumMap.isEmpty() && vendorCombineDatumMap.values().size()>0){
            for (JSONObject vendorCombineDatum : vendorCombineDatumMap.values()) {
                System.out.println(vendorCombineDatum.getString("dataKey"));
            }
        }

    }

    public static final List<String> VALUE_LIST_DEFAULT_LIST = Collections.unmodifiableList(Arrays.asList("vendor_name",
            "postal_code", "address", "contact", "vendor_code", "vendor_semiangle_name",
            "legal_representative", "tax_id", "check_net_no", "contact_phone", "contact_mail",
            "fax", "semiangle_address", "remark", "description"
    ));

    private static String text = "[{\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"vendor_name\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"腿と卵\",\n" +
            "\t\t\"showValue\": \"腿と卵\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"postal_code\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"1283774\",\n" +
            "\t\t\"showValue\": \"1283774\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"address\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"アドレスアドレスアドレスアドレス\",\n" +
            "\t\t\"showValue\": \"アドレスアドレスアドレスアドレス\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"contact\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"連絡先1\",\n" +
            "\t\t\"showValue\": \"連絡先1\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"vendor_code\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"002\",\n" +
            "\t\t\"showValue\": \"002\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"vendor_semiangle_name\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜｦﾝﾞﾟ01\",\n" +
            "\t\t\"showValue\": \"ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜｦﾝﾞﾟ01\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"legal_representative\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"取締役01\",\n" +
            "\t\t\"showValue\": \"取締役01\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"tax_id\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"9876543210\",\n" +
            "\t\t\"showValue\": \"9876543210\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"check_net_no\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"22334455\",\n" +
            "\t\t\"showValue\": \"22334455\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"contact_phone\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"18823982984\",\n" +
            "\t\t\"showValue\": \"18823982984\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"contact_mail\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"test2@huilianyi.com\",\n" +
            "\t\t\"showValue\": \"test2@huilianyi.com\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"fax\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"111-2222\",\n" +
            "\t\t\"showValue\": \"111-2222\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"semiangle_address\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜｦﾝﾞﾟ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ()/. ｢｣-\\\\\\\\ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜｦﾝﾞﾟ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ()/. ｢｣-\\\\\\\\ｱｲｳｴｵｶｷｸｹｺｻｼｽｾ\",\n" +
            "\t\t\"showValue\": \"ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜｦﾝﾞﾟ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ()/. ｢｣-\\\\\\\\ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜｦﾝﾞﾟ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ()/. ｢｣-\\\\\\\\ｱｲｳｴｵｶｷｸｹｺｻｼｽｾ\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"remark\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"メモメモメモメモメモメモメモメモメモメモ\",\n" +
            "\t\t\"showValue\": \"メモメモメモメモメモメモメモメモメモメモ\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"pre_defined\",\n" +
            "\t\t\"dataKey\": \"description\",\n" +
            "\t\t\"dataKeyCode\": \"\",\n" +
            "\t\t\"dataValue\": \"\",\n" +
            "\t\t\"showValue\": \"\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"cust_list\",\n" +
            "\t\t\"dataKey\": \"ce316eeb-b949-48a9-801e-1d86a889d7ae\",\n" +
            "\t\t\"dataKeyCode\": null,\n" +
            "\t\t\"dataValue\": \"0-男\",\n" +
            "\t\t\"showValue\": \"0-男\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"cust_list\",\n" +
            "\t\t\"dataKey\": \"17533c99-f469-4287-9dc4-d00d6302c987\",\n" +
            "\t\t\"dataKeyCode\": null,\n" +
            "\t\t\"dataValue\": \"01-大于\",\n" +
            "\t\t\"showValue\": \"01-大于\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"cust_list\",\n" +
            "\t\t\"dataKey\": \"b63afe4a-6e11-4029-8fc4-a2a4bbcd32c3\",\n" +
            "\t\t\"dataKeyCode\": null,\n" +
            "\t\t\"dataValue\": \"AD-安道尔\",\n" +
            "\t\t\"showValue\": \"AD-安道尔\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"cust_list\",\n" +
            "\t\t\"dataKey\": \"f8711e44-0d0f-4381-b582-9f72d2e4c96b\",\n" +
            "\t\t\"dataKeyCode\": null,\n" +
            "\t\t\"dataValue\": \"1-111\",\n" +
            "\t\t\"showValue\": \"1-111\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"cust_list\",\n" +
            "\t\t\"dataKey\": \"a2d439e5-c96a-4622-85d2-d88939142ebf\",\n" +
            "\t\t\"dataKeyCode\": null,\n" +
            "\t\t\"dataValue\": \"define01-define01\",\n" +
            "\t\t\"showValue\": \"define01-define01\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"input\",\n" +
            "\t\t\"dataKey\": \"b05d0f2c-5d84-4627-a46a-908857c3bf12\",\n" +
            "\t\t\"dataKeyCode\": null,\n" +
            "\t\t\"dataValue\": \"あああ\",\n" +
            "\t\t\"showValue\": \"あああ\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"input\",\n" +
            "\t\t\"dataKey\": \"dd30f484-be5e-46a9-b846-664050165921\",\n" +
            "\t\t\"dataKeyCode\": null,\n" +
            "\t\t\"dataValue\": \"いいい\",\n" +
            "\t\t\"showValue\": \"いいい\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"input\",\n" +
            "\t\t\"dataKey\": \"ad6c1b76-8171-4d00-b6af-fc63460edb1a\",\n" +
            "\t\t\"dataKeyCode\": null,\n" +
            "\t\t\"dataValue\": \"ううう\",\n" +
            "\t\t\"showValue\": \"ううう\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"input\",\n" +
            "\t\t\"dataKey\": \"d13be241-bde0-4c5d-928a-595233b31c6b\",\n" +
            "\t\t\"dataKeyCode\": null,\n" +
            "\t\t\"dataValue\": \"えええ\",\n" +
            "\t\t\"showValue\": \"えええ\"\n" +
            "\t}, {\n" +
            "\t\t\"dataType\": \"input\",\n" +
            "\t\t\"dataKey\": \"9fdc60cd-44c2-431d-8e5a-9fca459137f7\",\n" +
            "\t\t\"dataKeyCode\": null,\n" +
            "\t\t\"dataValue\": \"おおお\",\n" +
            "\t\t\"showValue\": \"おおお\"\n" +
            "\t}]";
}
